﻿#include "CWindow.h"

//创建一个非模式窗口
bool CWindow::Create(HINSTANCE hInstance, int nResource, HWND hWndParent, DLGPROC lpDialogFunc)
{
	this->m_hWnd = CreateDialog(hInstance, MAKEINTRESOURCE(nResource), hWndParent, lpDialogFunc);
	this->ShowWindow(SW_SHOW);
	this->UpdateWindow();

	//进入消息循环
	MSG msg;
	while(GetMessage(&msg, NULL, NULL, NULL))
	{
		if (!IsDialogMessage(this->m_hWnd, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	return true;
}

//创建一个模式窗口
bool CWindow::CreateModal(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc)
{
	
	return true;
}

//显示窗口
BOOL CWindow::ShowWindow(int nCmdShow /* = SW_SHOW */)
{
	return ::ShowWindow(this->m_hWnd, nCmdShow);
}

//强制更新窗口
BOOL CWindow::UpdateWindow()
{
	return ::UpdateWindow(this->m_hWnd);
}

//获取窗口句柄
HWND CWindow::GetHandle()
{
	return this->m_hWnd;
}